﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Tunnel.Devices.DeviceEntity
{
    public partial class FD : DeviceBase
    {
        public FD()
        {
            InitializeComponent();
        }

        public override string StatusDescription
        {
            get
            {
                return base.StatusDescription;
            }

            set
            {
                if (value == "正常")
                {
                    animationTimer.Stop();
                    this.Image = ResPic.火灾报警按钮正常;
                }
                if (value == "手报")
                {
                    this.Image = ResPic.火灾报警按钮报警;
                    animationTimer.Start();
                }
                if (value == "故障")
                {
                    animationTimer.Stop();
                    this.Image = ResPic.火灾报警按钮故障;
                }
                base.StatusDescription = value;
            }
        }
        Timer animationTimer = new Timer();
        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
            animationTimer.Interval = 500;
            animationTimer.Tick += animationtimer_Tick;
            this.Size = new Size(32, 32);
        }
        public override void SendCommand(CommandType commandType)
        {
            throw new NotImplementedException();
        }

        int flash = 0;
        private void animationtimer_Tick(object sender, EventArgs e)
        {

            switch (flash)
            {
                case 0: this.Image = ResPic.火灾报警按钮报警; flash = 1; break;
                case 1: this.Image = ResPic.火灾报警按钮正常; flash = 0; break;
            }
        }
    }
}
